import django_filters

from users.models import CustomerUser, User, Level, CustomerUserVice, CustomerUserViceInviterRecord
from activities.models import *
from merchants.models import *
from goods.models import LaunchedGoods, Goods, GoodsTagActivity, GoodsTagActivityLevelRelation
from orders.models import *
from vouchers.models import *
from cashbonus.models import CashActivity, CashActivityData, CashActivityLevel, CashActivityLevelRecord, CashActivityWhiteTable, CashActivityDataKeguan
from businesses.models import BindCardOrder, JoinCustomizeActivity
from alipaynfc.models import *


class CustomerUserFilter(django_filters.rest_framework.FilterSet):
    '''C端用户资料过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')

    class Meta:
        model = CustomerUser
        fields = ('create_time_begin', 'create_time_end')


class ActivityDataFilter(django_filters.rest_framework.FilterSet):
    '''邮米派发过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    state = django_filters.BaseInFilter(field_name='state', lookup_expr='in')
    activity = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')
    companyuser_id = django_filters.BaseInFilter(field_name='companyuser_id', lookup_expr='in')

    class Meta:
        model = ActivityData
        fields = ('create_time_begin', 'create_time_end', 'companyuser_id', 'state')


class ManagerUserFilter(django_filters.rest_framework.FilterSet):
    '''客户经理料过滤'''

    is_active = django_filters.BaseInFilter(field_name='is_active', lookup_expr='in')
    role_id = django_filters.BaseInFilter(field_name='role_id', lookup_expr='in')
    is_developer = django_filters.BaseInFilter(field_name='is_developer', lookup_expr='in')
    is_agreement = django_filters.BaseInFilter(field_name='is_agreement', lookup_expr='in')

    class Meta:
        model = User
        fields = ('is_active', 'role_id', 'is_developer', 'is_agreement')


class LevelFilter(django_filters.rest_framework.FilterSet):
    '''客户经理料过滤'''

    merchant_id = django_filters.BaseInFilter(field_name='merchantenter__merchant_id', lookup_expr='in')

    class Meta:
        model = Level
        fields = ('merchant_id',)


class MerchantFilter(django_filters.rest_framework.FilterSet):
    '''商户过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    is_mall = django_filters.BaseInFilter(field_name='is_mall', lookup_expr='in')
    applyment_state = django_filters.BaseInFilter(field_name='applyment_state', lookup_expr='in')
    verify_state = django_filters.BaseInFilter(field_name='verify_state', lookup_expr='in')
    subject_type = django_filters.BaseInFilter(field_name='subject_type', lookup_expr='in')
    merchantuser_id = django_filters.BaseInFilter(field_name='merchantuser_id', lookup_expr='in')

    class Meta:
        model = Merchant
        fields = ('create_time_begin', 'create_time_end', 'verify_state', 'is_mall', 'applyment_state', 'subject_type', 'merchantuser_id')


class LaunchedGoodsFilter(django_filters.rest_framework.FilterSet):
    '''商品过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    goods_id = django_filters.BaseInFilter(field_name='goods_id', lookup_expr='in')

    class Meta:
        model = LaunchedGoods
        fields = ('create_time_begin', 'create_time_end', 'goods_id')


class GoodsFilter(django_filters.rest_framework.FilterSet):
    '''商品过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    merchant_id = django_filters.BaseInFilter(field_name='merchant_id', lookup_expr='in')
    is_launched = django_filters.BaseInFilter(field_name='is_launched', lookup_expr='in')
    order_species = django_filters.BaseInFilter(field_name='order_species', lookup_expr='in')

    class Meta:
        model = Goods
        fields = ('create_time_begin', 'create_time_end', 'merchant_id', 'is_launched', 'order_species')


class OrderInfoFilter(django_filters.rest_framework.FilterSet):
    '''订单过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time", lookup_expr='lte')
    payment_time_begin = django_filters.DateTimeFilter(field_name="payment_time", lookup_expr='gte')
    payment_time_end = django_filters.DateTimeFilter(field_name="payment_time", lookup_expr='lte')
    use_time_begin = django_filters.DateTimeFilter(field_name="use_time", lookup_expr='gte')
    use_time_end = django_filters.DateTimeFilter(field_name="use_time", lookup_expr='lte')
    state = django_filters.BaseInFilter(field_name='state', lookup_expr='in')
    total_price_min = django_filters.NumberFilter(field_name="total_price", lookup_expr='gte')
    total_price_max = django_filters.NumberFilter(field_name="total_price", lookup_expr='lte')
    customeruser_id = django_filters.BaseInFilter(field_name='customer_user_id', lookup_expr='in')
    merchant_id = django_filters.BaseInFilter(field_name='merchant_id', lookup_expr='in')
    bill_id = django_filters.BaseInFilter(field_name='bill_id', lookup_expr='in')
    goods_id = django_filters.BaseInFilter(field_name='ordergoods__goods_id', lookup_expr='in')
    order_species = django_filters.BaseInFilter(field_name='order_species', lookup_expr='in')

    class Meta:
        model = OrderInfo
        fields = ('create_time_begin', 'create_time_end', 'state', 'total_price_min', 'total_price_max', 'customeruser_id', 'merchant_id', 'bill_id', 'goods_id',
                  'use_time_begin', 'use_time_end', 'order_species', 'payment_time_begin', 'payment_time_end')


class MerchantBillFilter(django_filters.rest_framework.FilterSet):
    '''商户账单'''

    receipts_time_begin = django_filters.DateTimeFilter(field_name="receipts_time__date", lookup_expr='gte')
    receipts_time_end = django_filters.DateTimeFilter(field_name="receipts_time__date", lookup_expr='lte')
    receipts_time = django_filters.DateTimeFilter(field_name="receipts_time__date", lookup_expr='lte')
    bill_state = django_filters.BaseInFilter(field_name='bill_state', lookup_expr='in')
    payable_amount_min = django_filters.NumberFilter(field_name="payable_amount", lookup_expr='gte')
    payable_amount_max = django_filters.NumberFilter(field_name="payable_amount", lookup_expr='lte')
    level_id = django_filters.BaseInFilter(field_name='merchant__level_id', lookup_expr='in')
    merchant_id = django_filters.BaseInFilter(field_name='merchant_id', lookup_expr='in')
    channel_id = django_filters.BaseInFilter(field_name='channel_id', lookup_expr='in')
    bill_type = django_filters.BaseInFilter(field_name='bill_type', lookup_expr='in')

    class Meta:
        model = MerchantBill
        fields = ('receipts_time_begin', 'receipts_time_end', 'bill_state', 'payable_amount_min', 'payable_amount_max', 'level_id', 'merchant_id', 'receipts_time', 'channel_id',
                  'bill_type')


class AliDiscountCouponFilter(django_filters.rest_framework.FilterSet):
    '''活动过滤'''

    coupon_status = django_filters.BaseInFilter(field_name='coupon_status', lookup_expr='in')
    coupon_channel = django_filters.BaseInFilter(field_name='coupon_channel', lookup_expr='in')
    coupon_way = django_filters.BaseInFilter(field_name='coupon_way', lookup_expr='in')
    distribution_platform_id = django_filters.BaseInFilter(field_name='distribution_platform_id', lookup_expr='in')
    publish_time_begin = django_filters.DateTimeFilter(field_name="publish_start_time__date", lookup_expr='gte')
    publish_time_end = django_filters.DateTimeFilter(field_name="publish_end_time__date", lookup_expr='lte')
    user_id = django_filters.BaseInFilter(field_name="user_id", lookup_expr='in')

    class Meta:
        model = AliDiscountCoupon
        fields = ('coupon_status', 'coupon_channel', 'coupon_way', 'distribution_platform_id', 'publish_time_begin', 'publish_time_end', 'user_id')


class CashActivityFilter(django_filters.rest_framework.FilterSet):
    '''活动过滤'''

    activity_state = django_filters.BaseInFilter(field_name='activity_state', lookup_expr='in')
    activity_type = django_filters.BaseInFilter(field_name='activity_type', lookup_expr='in')
    available_time_begin = django_filters.DateTimeFilter(field_name="available_begin_time__date", lookup_expr='gte')
    available_time_end = django_filters.DateTimeFilter(field_name="available_end_time__date", lookup_expr='lte')

    class Meta:
        model = CashActivity
        fields = ('activity_state', 'activity_type', 'available_time_begin', 'available_time_end')


class CashActivityLevelFilter(django_filters.rest_framework.FilterSet):
    '''活动过滤'''

    activity_id = django_filters.BaseInFilter(field_name='cash_activity_id', lookup_expr='in')
    dimensionality = django_filters.BaseInFilter(field_name='level__level', lookup_expr='in')

    class Meta:
        model = CashActivityLevel
        fields = ('activity_id', 'dimensionality')


class AliDiscountCouponLevelFilter(django_filters.rest_framework.FilterSet):
    '''活动过滤'''

    activity_id = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponLevel
        fields = ('activity_id', )


class CashActivityDataFilter(django_filters.rest_framework.FilterSet):
    '''领取明细过滤'''

    # cash_activity_level_id = django_filters.BaseInFilter(field_name='cash_activity_level_id', lookup_expr='in')
    state = django_filters.BaseInFilter(field_name='state', lookup_expr='in')
    level_id = django_filters.BaseInFilter(field_name='level_id', lookup_expr='in')
    activity_id = django_filters.BaseInFilter(field_name='cash_activity_id', lookup_expr='in')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')

    class Meta:
        model = CashActivityData
        fields = ('state', 'level_id', 'activity_id', 'create_time_begin', 'create_time_end')


class CashActivityDataKeguanFilter(django_filters.rest_framework.FilterSet):
    '''客管数据推送记录'''

    push_status = django_filters.BaseInFilter(field_name='push_status', lookup_expr='in')
    activity_id = django_filters.BaseInFilter(field_name='cashactivitydata__cash_activity_id', lookup_expr='in')
    push_time_begin = django_filters.DateTimeFilter(field_name="push_time__date", lookup_expr='gte')
    push_time_end = django_filters.DateTimeFilter(field_name="push_time__date", lookup_expr='lte')

    class Meta:
        model = CashActivityDataKeguan
        fields = ('push_status', 'activity_id', 'push_time_begin', 'push_time_end')


class CashActivityLevelRecordFilter(django_filters.rest_framework.FilterSet):
    '''领取明细过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    cash_activity_id = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')
    cash_activity_level_id = django_filters.BaseInFilter(field_name='activity_level_id', lookup_expr='in')
    operation_type = django_filters.BaseInFilter(field_name='operation_type', lookup_expr='in')

    class Meta:
        model = CashActivityLevelRecord
        fields = ('create_time_begin', 'create_time_end', 'cash_activity_id', 'cash_activity_level_id', 'operation_type')


class AliDiscountCouponInfoFilter(django_filters.rest_framework.FilterSet):
    '''领取明细过滤'''

    alidiscountcoupon_level_id = django_filters.BaseInFilter(field_name='alidiscountcoupon_level_id', lookup_expr='in')
    status = django_filters.BaseInFilter(field_name='status', lookup_expr='in')
    level_id = django_filters.BaseInFilter(field_name='level_id', lookup_expr='in')
    activity_id = django_filters.BaseInFilter(field_name='alidiscountcoupon_id', lookup_expr='in')
    coupon_channel = django_filters.BaseInFilter(field_name='coupon_channel', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponInfo
        fields = ('alidiscountcoupon_level_id', 'status', 'level_id', 'activity_id', 'coupon_channel')


class ChannelFilter(django_filters.rest_framework.FilterSet):

    channel_type = django_filters.BaseInFilter(field_name='channel_type', lookup_expr='in')

    class Meta:
        model = Channel
        fields = ('channel_type',)


class AliDiscountCouponMerchantFilter(django_filters.rest_framework.FilterSet):

    alidiscountcoupon_id = django_filters.BaseInFilter(field_name='alidiscountcoupon_id', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponMerchant
        fields = ('alidiscountcoupon_id',)


class WaivePaymentActivityFilter(django_filters.rest_framework.FilterSet):

    activity_state = django_filters.BaseInFilter(field_name='activity_state', lookup_expr='in')

    class Meta:
        model = WaivePaymentActivity
        fields = ('activity_state',)


class WaivePaymentAdvanceFilter(django_filters.rest_framework.FilterSet):

    waivepaymentactivity_id = django_filters.BaseInFilter(field_name='waivepaymentactivity_id', lookup_expr='in')
    operate_type = django_filters.BaseInFilter(field_name='operate_type', lookup_expr='in')

    class Meta:
        model = WaivePaymentAdvance
        fields = ('waivepaymentactivity_id', 'operate_type')


class WaivePaymentMerchantFilter(django_filters.rest_framework.FilterSet):

    payment_state = django_filters.BaseInFilter(field_name='payment_state', lookup_expr='in')
    waivepaymentadvance_id = django_filters.BaseInFilter(field_name='waivepaymentadvance_id', lookup_expr='in')
    waivepaymentactivity_id = django_filters.BaseInFilter(field_name='waivepaymentactivity_id', lookup_expr='in')

    class Meta:
        model = WaivePaymentMerchant
        fields = ('payment_state', 'waivepaymentadvance_id', 'waivepaymentactivity_id')


class WaivePaymentOrderFilter(django_filters.rest_framework.FilterSet):

    waivepaymentmerchant_id = django_filters.BaseInFilter(field_name='waivepaymentmerchant_id', lookup_expr='in')
    waivepaymentactivity_id = django_filters.BaseInFilter(field_name='waivepaymentactivity_id', lookup_expr='in')
    is_hit = django_filters.BaseInFilter(field_name='is_hit', lookup_expr='in')

    class Meta:
        model = WaivePaymentOrder
        fields = ('waivepaymentmerchant_id', 'waivepaymentactivity_id', 'is_hit')


class MerchantSettlementRecordFilter(django_filters.rest_framework.FilterSet):

    settlement_time_begin = django_filters.DateTimeFilter(field_name="settlement_time__date", lookup_expr='gte')
    settlement_time_end = django_filters.DateTimeFilter(field_name="settlement_time__date", lookup_expr='lte')
    settlement_time = django_filters.DateTimeFilter(field_name="settlement_time__date", lookup_expr='gt')
    status = django_filters.BaseInFilter(field_name='status', lookup_expr='in')
    channel_id = django_filters.BaseInFilter(field_name='channel_id', lookup_expr='in')
    is_bind = django_filters.BaseInFilter(field_name='is_bind', lookup_expr='in')
    merchant_id = django_filters.BaseInFilter(field_name='merchant_id', lookup_expr='in')

    class Meta:
        model = MerchantSettlementRecord
        fields = ('settlement_time_begin', 'settlement_time_end', 'status', 'channel_id', 'is_bind', 'settlement_time', 'merchant_id')


class SYOrderInfoFilter(django_filters.rest_framework.FilterSet):

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    order_status = django_filters.BaseInFilter(field_name='order_status', lookup_expr='in')

    class Meta:
        model = SYOrderInfo
        fields = ('create_time_begin', 'create_time_end', 'order_status')


class CustomizeActivityFilter(django_filters.rest_framework.FilterSet):

    activity_status = django_filters.BaseInFilter(field_name='activity_status', lookup_expr='in')
    activity_type = django_filters.BaseInFilter(field_name='activity_type', lookup_expr='in')

    class Meta:
        model = CustomizeActivity
        fields = ('activity_status', 'activity_type')


class CustomizeActivityLevelFilter(django_filters.rest_framework.FilterSet):
    '''活动过滤'''

    customizeactivity_id = django_filters.BaseInFilter(field_name='customizeactivity_id', lookup_expr='in')

    class Meta:
        model = CustomizeActivityLevel
        fields = ('customizeactivity_id', )


class CustomizeActivityFlipCARDSFilter(django_filters.rest_framework.FilterSet):

    open_status = django_filters.BaseInFilter(field_name='open_status', lookup_expr='in')
    customizeactivity_id = django_filters.BaseInFilter(field_name='customizeactivity_id', lookup_expr='in')
    received_time_begin = django_filters.DateTimeFilter(field_name="received_time__date", lookup_expr='gte')
    received_time_end = django_filters.DateTimeFilter(field_name="received_time__date", lookup_expr='lte')

    class Meta:
        model = CustomizeActivityFlipCARDS
        fields = ('open_status', 'customizeactivity_id', 'received_time_begin', 'received_time_end')


class BindCardOrderFilter(django_filters.rest_framework.FilterSet):

    order_status = django_filters.BaseInFilter(field_name='order_status', lookup_expr='in')
    prize_status = django_filters.BaseInFilter(field_name='prize_status', lookup_expr='in')
    bank_type = django_filters.BaseInFilter(field_name='bank_type_sign', lookup_expr='in')
    customizeactivity_id = django_filters.BaseInFilter(field_name='customizeactivity_id', lookup_expr='in')
    received_time_begin = django_filters.DateTimeFilter(field_name="customizeactivityflipcards__received_time__date", lookup_expr='gte')
    received_time_end = django_filters.DateTimeFilter(field_name="customizeactivityflipcards__received_time__date", lookup_expr='lte')

    class Meta:
        model = BindCardOrder
        fields = ('order_status', 'prize_status', 'customizeactivity_id', 'received_time_begin', 'received_time_end', 'bank_type')


class JoinCustomizeActivityFilter(django_filters.rest_framework.FilterSet):

    is_join = django_filters.BaseInFilter(field_name='is_join', lookup_expr='in')
    count = django_filters.BaseInFilter(field_name='count', lookup_expr='in')
    customizeactivity_id = django_filters.BaseInFilter(field_name='customizeactivity_id', lookup_expr='in')
    join_time_begin = django_filters.DateTimeFilter(field_name="join_time__date", lookup_expr='gte')
    join_time_end = django_filters.DateTimeFilter(field_name="join_time__date", lookup_expr='lte')

    class Meta:
        model = JoinCustomizeActivity
        fields = ('is_join', 'join_time_begin', 'join_time_end', 'count', 'customizeactivity_id')


class CustomerUserViceFilter(django_filters.rest_framework.FilterSet):

    is_wyh_customer = django_filters.BaseInFilter(field_name='is_wyh_customer', lookup_expr='in')
    is_subscribe = django_filters.BaseInFilter(field_name='is_subscribe', lookup_expr='in')
    obtain_point_min = django_filters.NumberFilter(field_name="obtain_point", lookup_expr='gte')
    obtain_point_max = django_filters.NumberFilter(field_name="obtain_point", lookup_expr='lte')

    class Meta:
        model = CustomerUserVice
        fields = ('is_wyh_customer', 'is_subscribe', 'obtain_point_min', 'obtain_point_max')


class MerchantEightEightDrawFilter(django_filters.rest_framework.FilterSet):

    state = django_filters.BaseInFilter(field_name='state', lookup_expr='in')
    activity_id = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    amount_min = django_filters.NumberFilter(field_name="amount", lookup_expr='gte')
    amount_max = django_filters.NumberFilter(field_name="amount", lookup_expr='lte')

    class Meta:
        model = MerchantEightEightDraw
        fields = ('state', 'create_time_begin', 'create_time_end', 'amount_min', 'amount_max', 'activity_id')


class MerchantBusinessQRCodeFilter(django_filters.rest_framework.FilterSet):

    is_bind = django_filters.BaseInFilter(field_name='is_bind', lookup_expr='in')
    is_c_bind = django_filters.BaseInFilter(field_name='is_c_bind', lookup_expr='in')
    bind_time_begin = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='gte')
    bind_time_end = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='lte')

    class Meta:
        model = MerchantBusinessQRCode
        fields = ('is_bind', 'bind_time_begin', 'bind_time_end', 'is_c_bind')


class UpdateStockUsableMerchantFilter(django_filters.rest_framework.FilterSet):
    '''添加用户申请单过滤'''

    alidiscountcoupon_id = django_filters.BaseInFilter(field_name='alidiscountcoupon_id', lookup_expr='in')
    apply_state = django_filters.BaseInFilter(field_name='apply_state', lookup_expr='in')

    class Meta:
        model = UpdateStockUsableMerchant
        fields = ('alidiscountcoupon_id', 'apply_state')


class MerchantBusinessQRCodeVisitFilter(django_filters.rest_framework.FilterSet):
    '''添加用户申请单过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    qrcode_id = django_filters.BaseInFilter(field_name='qrcode_id', lookup_expr='in')

    class Meta:
        model = MerchantBusinessQRCodeVisit
        fields = ('create_time_begin', 'create_time_end', 'qrcode_id')


class CustomerUserViceInviterRecordFilter(django_filters.rest_framework.FilterSet):
    '''添加用户申请单过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    inviter_time_begin = django_filters.DateTimeFilter(field_name="inviter_time__date", lookup_expr='gte')
    inviter_time_end = django_filters.DateTimeFilter(field_name="inviter_time__date", lookup_expr='lte')
    qrcode_id = django_filters.BaseInFilter(field_name='qrcode_id', lookup_expr='in')
    is_inviter = django_filters.BaseInFilter(field_name='is_inviter', lookup_expr='in')

    class Meta:
        model = CustomerUserViceInviterRecord
        fields = ('create_time_begin', 'create_time_end', 'qrcode_id', 'inviter_time_begin', 'inviter_time_end', 'is_inviter')


class AliDiscountCouponSyncWYHRecordFilter(django_filters.rest_framework.FilterSet):
    '''添加用户申请单过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    sync_status = django_filters.BaseInFilter(field_name='sync_status', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponSyncWYHRecord
        fields = ('sync_status', 'create_time_begin', 'create_time_end')


class MerchantEightEightActivityFilter(django_filters.rest_framework.FilterSet):

    activity_status = django_filters.BaseInFilter(field_name='activity_status', lookup_expr='in')
    activity_type = django_filters.BaseInFilter(field_name='activity_type', lookup_expr='in')

    class Meta:
        model = MerchantEightEightActivity
        fields = ('activity_status', 'activity_type')


class MerchantEightEightActivityPrizeFilter(django_filters.rest_framework.FilterSet):

    activity_id = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')

    class Meta:
        model = MerchantEightEightActivityPrize
        fields = ('activity_id', )


class OrderAdvanceFilter(django_filters.rest_framework.FilterSet):

    order_id = django_filters.BaseInFilter(field_name='order_id', lookup_expr='in')

    class Meta:
        model = OrderAdvance
        fields = ('order_id', )


class AliDiscountCouponGoodsAvailableFilter(django_filters.rest_framework.FilterSet):

    goods_id = django_filters.BaseInFilter(field_name='goods_id', lookup_expr='in')
    alidiscountcoupon_id = django_filters.BaseInFilter(field_name='alidiscountcoupon_id', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponGoodsAvailable
        fields = ('alidiscountcoupon_id', )


class MerchantMonthlyBillFilter(django_filters.rest_framework.FilterSet):

    merchant_id = django_filters.BaseInFilter(field_name='merchant_id', lookup_expr='in')
    settlement_amount_min = django_filters.NumberFilter(field_name="settlement_amount", lookup_expr='gte')
    settlement_amount_max = django_filters.NumberFilter(field_name="settlement_amount", lookup_expr='lte')
    business_no = django_filters.BaseInFilter(field_name='merchant__wyfMerchantID', lookup_expr='in')
    receipts_time_begin = django_filters.DateTimeFilter(field_name="receipts_time__date", lookup_expr='gte')
    receipts_time_end = django_filters.DateTimeFilter(field_name="receipts_time__date", lookup_expr='lte')

    class Meta:
        model = MerchantMonthlyBill
        fields = ('settlement_amount_min', 'settlement_amount_min', 'merchant_id', 'business_no', 'receipts_time_begin', 'receipts_time_end')


class ExpressFilter(django_filters.rest_framework.FilterSet):

    deliverystatus = django_filters.BaseInFilter(field_name='deliverystatus', lookup_expr='in')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    sign_time_begin = django_filters.DateTimeFilter(field_name="sign_time__date", lookup_expr='gte')
    sign_time_end = django_filters.DateTimeFilter(field_name="sign_time__date", lookup_expr='lte')

    class Meta:
        model = Express
        fields = ('deliverystatus', 'create_time_begin', 'create_time_end', 'sign_time_begin', 'sign_time_end')


class MerchantBankQRCodeQuestFilter(django_filters.rest_framework.FilterSet):

    file_type = django_filters.BaseInFilter(field_name='file_type', lookup_expr='in')
    file_status = django_filters.BaseInFilter(field_name='file_status', lookup_expr='in')

    class Meta:
        model = MerchantBankQRCodeQuest
        fields = ('file_type', 'file_status')


class MerchantBankQRCodeFilter(django_filters.rest_framework.FilterSet):

    is_download = django_filters.BaseInFilter(field_name='is_download', lookup_expr='in')

    class Meta:
        model = MerchantBankQRCode
        fields = ('is_download', )


class MerchantBankQRCodeBindDataFilter(django_filters.rest_framework.FilterSet):

    card_type = django_filters.BaseInFilter(field_name='card_type', lookup_expr='in')
    is_first = django_filters.BaseInFilter(field_name='is_first', lookup_expr='in')
    bank_qrcode_id = django_filters.BaseInFilter(field_name='bank_qrcode_id', lookup_expr='in')
    bind_time_begin = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='gte')
    bind_time_end = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='lte')

    class Meta:
        model = MerchantBankQRCodeBindData
        fields = ('card_type', 'is_first', 'bind_time_begin', 'bind_time_end', 'bank_qrcode_id')


class MErchantBankQPCodeStatisticsFilter(django_filters.rest_framework.FilterSet):

    bank_qrcode_id = django_filters.BaseInFilter(field_name='bank_qrcode_id', lookup_expr='in')
    bind_time_begin = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='gte')
    bind_time_end = django_filters.DateTimeFilter(field_name="bind_time__date", lookup_expr='lte')

    class Meta:
        model = MErchantBankQPCodeStatistics
        fields = ('bind_time_begin', 'bind_time_end', 'bank_qrcode_id')


class MerchantUserFilter(django_filters.rest_framework.FilterSet):

    is_psbc_card = django_filters.BaseInFilter(field_name='is_psbc_card', lookup_expr='in')
    lucky_bag_max = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='lte')
    lucky_bag_min = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='gte')

    class Meta:
        model = MerchantUser
        fields = ('is_psbc_card', 'lucky_bag_max', 'lucky_bag_min')


class LuckyBagChildActivityDataFilter(django_filters.rest_framework.FilterSet):

    lucky_status = django_filters.BaseInFilter(field_name='lucky_status', lookup_expr='in')
    luckybagchildactivity_id = django_filters.BaseInFilter(field_name='luckybagchildactivity_id', lookup_expr='in')
    merchantuser_id = django_filters.BaseInFilter(field_name='merchantuser_id', lookup_expr='in')
    lucky_bag_max = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='lte')
    lucky_bag_min = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='gte')
    received_time_begin = django_filters.DateTimeFilter(field_name="received_time__date", lookup_expr='gte')
    received_time_end = django_filters.DateTimeFilter(field_name="received_time__date", lookup_expr='lte')

    class Meta:
        model = LuckyBagChildActivityData
        fields = ('lucky_status', 'lucky_bag_max', 'lucky_bag_min', 'luckybagchildactivity_id', 'received_time_begin', 'received_time_end', 'merchantuser_id')


class LuckyBagRecordFilter(django_filters.rest_framework.FilterSet):

    operate_type = django_filters.BaseInFilter(field_name='operate_type', lookup_expr='in')
    merchantuser_id = django_filters.BaseInFilter(field_name='merchantuser_id', lookup_expr='in')
    lucky_bag_max = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='lte')
    lucky_bag_min = django_filters.NumberFilter(field_name="lucky_bag", lookup_expr='gte')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')

    class Meta:
        model = LuckyBagRecord
        fields = ('operate_type', 'lucky_bag_max', 'lucky_bag_min', 'create_time_begin', 'create_time_end', 'merchantuser_id')


class MerchantEnterQuestFilter(django_filters.rest_framework.FilterSet):

    file_status = django_filters.BaseInFilter(field_name='file_status', lookup_expr='in')

    class Meta:
        model = MerchantEnterQuest
        fields = ('file_status',)


class OrderInfoGROUPFilter(django_filters.rest_framework.FilterSet):

    group_status = django_filters.BaseInFilter(field_name='group_status', lookup_expr='in')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    expired_time_begin = django_filters.DateTimeFilter(field_name="expired_time__date", lookup_expr='gte')
    expired_time_end = django_filters.DateTimeFilter(field_name="expired_time__date", lookup_expr='lte')
    group_order_num_max = django_filters.NumberFilter(field_name="group_order_num", lookup_expr='lte')
    group_order_num_min = django_filters.NumberFilter(field_name="group_order_num", lookup_expr='gte')

    class Meta:
        model = OrderInfoGROUP
        fields = ('group_status', 'create_time_begin', 'create_time_begin', 'expired_time_begin', 'expired_time_end',
                  'group_order_num_max', 'group_order_num_min')


class MerchantNFCDeviceTradeFilter(django_filters.rest_framework.FilterSet):

    trade_time_begin = django_filters.DateTimeFilter(field_name="trade_time__date", lookup_expr='gte')
    trade_time_end = django_filters.DateTimeFilter(field_name="trade_time__date", lookup_expr='lte')
    total_amount_max = django_filters.NumberFilter(field_name="total_amount", lookup_expr='lte')
    total_amount_min = django_filters.NumberFilter(field_name="total_amount", lookup_expr='gte')

    class Meta:
        model = MerchantNFCDeviceTrade
        fields = ('trade_time_begin', 'trade_time_end', 'total_amount_max', 'total_amount_min')


class GoodsTagActivityFilter(django_filters.rest_framework.FilterSet):

    activity_state = django_filters.BaseInFilter(field_name='activity_state', lookup_expr='in')

    class Meta:
        model = GoodsTagActivity
        fields = ('activity_state',)


class GoodsTagActivityLevelRelationFilter(django_filters.rest_framework.FilterSet):

    goods_tag_activity_id = django_filters.BaseInFilter(field_name='goods_tag_activity_id', lookup_expr='in')

    class Meta:
        model = GoodsTagActivityLevelRelation
        fields = ('goods_tag_activity_id',)


class OrderSchengleFilter(django_filters.rest_framework.FilterSet):

    order_state = django_filters.BaseInFilter(field_name='order_state', lookup_expr='in')

    class Meta:
        model = OrderSchengle
        fields = ('order_state',)


class NFCDeviceFilter(django_filters.rest_framework.FilterSet):

    device_type = django_filters.BaseInFilter(field_name='device_type', lookup_expr='in')
    is_lighten = django_filters.BaseInFilter(field_name='is_lighten', lookup_expr='in')
    rewards_status = django_filters.BaseInFilter(field_name='rewards_status', lookup_expr='in')
    lighten_time_begin = django_filters.DateTimeFilter(field_name="lighten_time__date", lookup_expr='gte')
    lighten_time_end = django_filters.DateTimeFilter(field_name="lighten_time__date", lookup_expr='lte')

    class Meta:
        model = NFCDevice
        fields = ('device_type', 'is_lighten', 'lighten_time_begin', 'lighten_time_end', 'rewards_status')


class NFCDeviceBountyQuestFilter(django_filters.rest_framework.FilterSet):

    quest_status = django_filters.BaseInFilter(field_name='quest_status', lookup_expr='in')
    device_id = django_filters.BaseInFilter(field_name='device_id', lookup_expr='in')
    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')

    class Meta:
        model = NFCDeviceBountyQuest
        fields = ('quest_status', 'device_id', 'create_time_begin', 'create_time_end')


class NFCDeviceBountyQuestScheduleFilter(django_filters.rest_framework.FilterSet):

    quest_id = django_filters.BaseInFilter(field_name='quest_id', lookup_expr='in')

    class Meta:
        model = NFCDeviceBountyQuestSchedule
        fields = ('quest_id',)


class CashActivityWhiteTableFilter(django_filters.rest_framework.FilterSet):

    cashactivity_id = django_filters.BaseInFilter(field_name='cashactivity_id', lookup_expr='in')
    is_admin = django_filters.BaseInFilter(field_name='is_admin', lookup_expr='in')

    class Meta:
        model = CashActivityWhiteTable
        fields = ('cashactivity_id', 'is_admin')


class AliDiscountCouponMerchantTableHistoryFilter(django_filters.rest_framework.FilterSet):

    add_type = django_filters.BaseInFilter(field_name='add_type', lookup_expr='in')
    data_type = django_filters.BaseInFilter(field_name='data_type', lookup_expr='in')
    table_type = django_filters.BaseInFilter(field_name='table_type', lookup_expr='in')
    add_state = django_filters.BaseInFilter(field_name='add_state', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponMerchantTableHistory
        fields = ('add_type', 'data_type', 'table_type', 'add_state')


class AliDiscountCouponMerchantTableFilter(django_filters.rest_framework.FilterSet):

    is_white = django_filters.BaseInFilter(field_name='is_white', lookup_expr='in')
    is_black = django_filters.BaseInFilter(field_name='is_black', lookup_expr='in')

    class Meta:
        model = AliDiscountCouponMerchantTable
        fields = ('is_white', 'is_black')


